# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=cleverhans
pkgver=v4.0.0.r7.g574efc1
pkgrel=1
pkgdesc='Python library to benchmark machine learning systems vulnerability to adversarial examples.'
arch=('any')
groups=('blackarch' 'blackarch-ai' 'blackarch-defensive')
url='https://github.com/cleverhans-lab/cleverhans'
license=('MIT')
depends=('python' 'python-absl' 'python-easydict' 'python-joblib'
         'python-matplotlib' 'python-mnist' 'python-nose' 'python-numpy'
         'python-pycodestyle' 'python-pytorch' 'python-scipy' 'python-six'
         'python-tensorflow-probability' 'python-tqdm')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools'
             'python-wheel')
source=("git+https://github.com/cleverhans-lab/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  cd $pkgname

  python -m build --wheel --no-isolation
}

package() {
  cd $pkgname

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  python -m installer --destdir="$pkgdir" dist/*.whl
}

